//
//  ZRMainViewController.swift
//  XJ8XWB
//
//  Created by 中二 on 2016/10/23.
//  Copyright © 2016年 中二. All rights reserved.
//

import UIKit

class ZRMainViewController: UITabBarController {

    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = ZRJiaHao()
        
        tabBar.DJiaHao = {
            
            print("点击加号了！")
            
        }
        setValue(tabBar, forKey: "tabBar")
        
        // Do any additional setup after loading the view.
        // 添加子控制器
        addChildViewController(vc: ZRSYViewController(), title: "首页", imgName: "tabbar_home")
        addChildViewController(vc: ZRXxViewController(), title: "消息", imgName: "tabbar_message_center")
        addChildViewController(vc: ZRFXViewController(), title: "发现", imgName: "tabbar_discover")
        addChildViewController(vc: ZRWoViewController(), title: "我", imgName: "tabbar_profile")
      
        
        
    }
    
    func addChildViewController(vc:UIViewController,title:String,imgName:String) {
        
        vc.title = title
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:ZRZhuColor], for: UIControlState.selected)
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        
        let vcNav = ZRMainNavViewController(rootViewController:vc)
        addChildViewController(vcNav)
        
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
